<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
?>
<?php
/**
 * @see Enterprise_GiftCardAccount_Block_Account_Redeem
 */
?>
<div class="page-head">
    <h2><?php echo Mage::helper('enterprise_giftcardaccount')->__('Gift Card'); ?></h2>
</div>
<div class="giftcardaccount account-block">
    <span id="gc-please-wait" class="please-wait" style="display:none;">
        <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="" class="v-middle" /> <?php echo $this->__('Please wait, loading...') ?>
    </span>
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <form id="giftcard-form" action="<?php echo $this->getUrl('*/*/*') ?>" method="post"<?php if (!$this->canRedeem()): ?> onsubmit="giftCardAccountLookupBalance(); return false;"<?php endif; ?>>
        <div id="giftcard_balance_lookup"></div>
        <div class="fieldset">
            <ul class="form-list">
                <li>
                    <label for="giftcard_code"><?php echo $this->__('Enter gift card code') ?></label>
                    <div class="input-box">
                        <input class="required-entry input-text" id="giftcard_code" name="giftcard_code" value="<?php echo $this->getCurrentGiftcard(); ?>" />
                    </div>
                </li>
            </ul>
        </div>
        <div class="buttons-set form-buttons btn-only">
            <button class="form-button form-button-alt giftcard check-gc-status" id="gca_balance_button" type="button" value="<?php echo $this->__('Check Gift Card') ?>"><span><span><?php echo $this->__('Check Gift Card') ?></span></span></button>
<?php if ($this->canRedeem()): ?>
            <button class="form-button form-button-alt giftcard" onclick="giftcardForm.submit()" type="button" value="<?php echo $this->__('Redeem Gift Card') ?>"><span><span><?php echo $this->__('Redeem Gift Card') ?></span></span></button>
<?php endif; ?>
            
        </div>
    </form>
    <script type="text/javascript">
    //<![CDATA[
    var giftcardForm = new VarienForm('giftcard-form');
    function giftCardAccountLookupBalance() {
        new Ajax.Updater('giftcard_balance_lookup', '<?php echo Mage::getUrl('enterprise_giftcardaccount/cart/quickCheck', array('_secure' => true)) ?>', {
            onCreate: function() {
                $('gc-please-wait').show()
            },
            onComplete: function() {
                $('gc-please-wait').hide();
                if ($$('.col-main .messages')) {
                    $$('.col-main .messages').invoke('hide');
                }
            },
            parameters : {giftcard_code : $('giftcard_code').value}
        });
    }
    $('gca_balance_button').observe('click', giftCardAccountLookupBalance);
    //]]>
    </script>
</div>
